<!DOCTYPE html>
<html>
<head>
    {include file="layout:_meta" /}
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">订单编号</label>
        <div class="layui-input-block">
            <input type="text"  placeholder="" lay-reqtext="" readonly="readonly"
                   autocomplete="off" value="{:isset($list.sn)?$list.sn:''}" class="layui-input" style="border: none;">
        </div>
    </div>

<div class="layui-form-item">
    <label class="layui-form-label">下单时间</label>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" nplaceholder="yyyy-MM-dd HH:mm:ss"
               value="{:isset($list.create_time)?$list.create_time:''}" readonly="readonly" style="border: none;">
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">结束时间</label>
    <div class="layui-input-inline">
        <input type="text" class="layui-input"  placeholder="yyyy-MM-dd HH:mm:ss"
               value="{:isset($list.update_time)?$list.update_time:''}" readonly="readonly" style="border: none;">
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">订单总金额</label>
    <div class="layui-input-block">
        <input type="text" class="layui-input"  placeholder=""
               value="{:isset($list.total_price)?$list.total_price:'0'}" readonly="readonly" style="border: none;">
    </div>
    <div class="layui-input-block" style="color: #c0ccda">订单总金额:未打折扣订单商品总额金额</div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">成交金额</label>
    <div class="layui-input-block">
        <input type="number" name="price" lay-verify="required" placeholder="订单实付金额" lay-reqtext=""
               autocomplete="off" value="{:isset($list.price)?$list.price:''}" class="layui-input">
    </div>
    <div class="layui-input-block" style="color: #c0ccda">成交金额:折扣后订单成交金额（实付金额）,管理员可修改</div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">订单状态</label>
    <div class="layui-input-block">
        {if condition="isset($list.state)&&  $list.state eq 0"}
        <div class="layui-input" readonly="readonly" style="border: none;color: red;line-height:38px;" >订单取消</div>
        {elseif $list.state eq 1 /}
        <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;" >待接订单</div>
        {elseif $list.state eq 2 /}
        <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;" >已接订单</div>
        {elseif $list.state eq 3 /}
        <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;" >订单完成</div>
        {/if}
    </div>
</div>
<div class="layui-form-item">
        <label class="layui-form-label">付款状态</label>
        <div class="layui-input-block">
            {if condition="isset($list.pay_state)&& $list.pay_state eq '0'"}
            <div class="layui-input" readonly="readonly" style="border: none;color: red;line-height:38px;" >未付款</div>
            {else /}
            <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;" >已付款</div>
            {/if}
        </div>
    </div>

<div class="layui-form-item layui-hide">
    <input type="hidden" name="id" value="{:isset($list['id'])?$list['id']:''}">
    <input type="hidden" name="token" value="{:isset($list['token'])?$list['token']:''}">
    <input type="button" lay-submit lay-filter="addEdit" id="addEdit" value="确认">
</div>
</div>
{include file="layout:_footer" /}
<script>
    layui.config({
        base: '__static__/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload', 'xmSelect', 'laydate'], function () {
        var form = layui.form, $ = layui.$, upload = layui.upload, xmSelect = layui.xmSelect, laydate = layui.laydate;

        //角色多选框
        var xm_select = xmSelect.render({
            el: '#xm-select',
            tips: '请选择分组',
            prop: {name: 'name', value: 'id'},
            name: 'cate_id',
            layVerify: 'required',
            data: []
        });

        //获取数据以及赋值
        $.get("{:url('ad/edit')}", {id: "{:isset($list['id'])?$list['id']:''}"}, function (res) {
            xm_select.update({data: res.roleList});
            xm_select.setValue(res.role)
        });

        //拖拽上传 单图上传
        var uploadInst = upload.render({
            elem: '#headImg'
            , url: "/admin/index/upload_img" + '?uptype=ad'
            , size: 120
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                console.log(res.code, '==========================>图片上传返回<');
                //如果上传失败
                if (res.code != 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
                /*   console.log(res.data.src);*/
                //   window.parent.uploadHeadImage(res.files);
                var demoText = $('#demoText');
                // $('#ad_img').val(res.files);
                $('#ad_img').val(res.data.img_url);
                console.log(demoText, '===========>,<!!!');
                demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        //end
        //日期时间选择器
        laydate.render({
            elem: '#starttime'
            , type: 'datetime'
            , trigger: 'click'//呼出事件改成click
        });
        //日期时间选择器
        laydate.render({
            elem: '#endtime'
            , type: 'datetime'
            , trigger: 'click'//呼出事件改成click
        });
        // 监听类型操作
        $("#typevalue").hide();
        form.on('select(type)', function (data) {
            console.log(data)
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            var value = data.value;
            if (value == "1") {
                $("#typevalue").hide();
            } else {
                $("#typevalue").show();
            }
        });
        //状态
        form.on('switch(state)', function (data) {
            this.value = this.checked ? 1 : 0;
        });

    })
</script>
</body>
</html>